 // 尝试用跟Object相同的方式去监听
 const objt = []

 function defineProperty(obj, key, val) {
   Object.defineProperty(obj, key, {
     enumerable: true,
     configurable: true,
     get: () => {
       console.log('getter')
       return val
     },
     set: newVal => {
       if (val === newVal) {
         return
       }
       console.log('setter')
       val == newVal
     }
   })
 }
 // 以下三种定义方式没有任何的反应
 defineProperty(objt, '0', 2)
 objt[0] = 2
 objt.push(1)

//  定义数组拦截器
const arrayProp = Array.prototype
const arrayMethods = Object.create(arrayProp)
for (let v of ['push', 'pop'].values()) {
  Reflect.defineProperty(arrayMethods, v, {
    value: function (...args) {
      console.log(v)
      return Reflect.apply(Reflect.get(arrayProp, v), this, args)
    }
  })
}
console.log( Array.prototype === Reflect.getPrototypeOf(new Array()))   
let arr = []
Reflect.setPrototypeOf(arr, arrayMethods)
arr.push(1)
